<?php 
/**
 * views module connection
 * 
 * implementing of hook_views_data()
 * 
 * @see <base_url>/help/views/api-tables
 */
function customer_video_views_views_data()
{
  $data['customer_video_views']['table']['group'] = t('Customer views');
  
  $data['customer_video_views']['table']['base'] = array(
    'field' => 'uid', 
    'title' => t('Customer users video views table'), 
    'help' => t("Customer users video views table."), 
  );
  
  
  $data['customer_video_views']['table']['join'] = array(
    // Index this array by the table name to which this table refers.
    // 'left_field' is the primary key in the referenced table.
    // 'field' is the foreign key in this table.
    'uk_orders' => array(
      'left_field' => 'uid', 
      'field' => 'uid',
    ),
    'node' => array(
      'left_field' => 'nid', 
      'field' => 'nid',
    ),
  );
   
  $data['customer_video_views']['uid'] = array(
      'title' => t('User id of a customer'), 
      'help' => t('User id of a customer'),
      'relationship' => array(
        'base' => 'uk_orders', 
        'field' => 'uid', 
        'handler' => 'views_handler_relationship', 
        'label' => t('Customer views - user'),
    ),
  );
   
  $data['customer_video_views']['nid'] = array(
      'title' => t('Node id of the video'), 
      'help' => t('Node id of the video, related to {node}'),
      'relationship' => array(
        'base' => 'node', 
        'field' => 'nid', 
        'handler' => 'views_handler_relationship', 
        'label' => t('Customer views - nid of the video'),
    ),
  );
  
  $data['customer_video_views']['count'] = array(
    'title' => t('Number of customer views'), 
    'help' => t('Number of customer views'), 
    'field' => array(
      'handler' => 'views_handler_field_numeric', 
      'click sortable' => TRUE,
    ), 
    'filter' => array(
      'handler' => 'views_handler_filter_numeric',
    ), 
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
    'argument' => array(
      'handler' => 'views_handler_argument_numeric',
    ),
  );
  
  $data['customer_video_views']['time'] = array(
    'title' => t('Latest time view'), 
    'help' => t('Latest time view'), 
    'field' => array(
      'handler' => 'views_handler_field_numeric', 
      'click sortable' => TRUE,
    ), 
    'filter' => array(
      'handler' => 'views_handler_filter_numeric',
    ), 
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );
  
  return $data;
}


